package com.ty.day5;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;

public class F {
    int f1(FuncInterface ai, int a, int b) {
        return ai.sum(a, b);
    }

    boolean f2(BInterface b, int age) {
        return b.isAge(age);
    }

    void f3(BInterface b, DInterface c) {
        int r = c.randomInt(100);
        if (b.isAge(r)) {
            System.out.println("成年人.");
        } else {
            System.out.println("未成年人.");
        }
    }
}

class TestF {
    public static void main111(String[] args) {
        F f = new F();
        f.f2(age -> {
            if (age > 18)
                return true;
            return false;
        }, 20);

        f.f3((age) -> {
            if (age > 18)
                return true;
            return false;
        }, () -> {
            return 0;
        });
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd h:mm-ss");
        Date date = new Date();
        String s = sdf.format(date);
        System.out.println(s);

    }

    public static void main1(String[] args) {
        F f = new F();
        f.f1(new FuncInterface() { // 采用匿名内部类。
            @Override
            public int sum(int a, int b) {
                return a + b;
            }
        }, 10, 20);

        // AInterface ai = (a,b)->{return  a+b;};
        // System.out.println(ai.getClass()); // ai指向的对象的类型class day5.TestF$$Lambda$14/0x0000000800066040

        int sum = f.f1((a, b) -> {
            return a + b;
        }, 4, 5);


    }
}

 class  AA {
    void Show() {
        System.out.println("我喜欢Java!");
    }
}

class BB  {
    int[] arr = new int[10];
    void Show() {
        System.out.println("喜欢C++!");
    }

    public static void main(String[] args) {

    }
}

